package controller

import (
	"fmt"
	"goapp-web-server/app/middleware/jwt"
	"goapp-web-server/app/models"
	"goapp-web-server/app/service"

	"github.com/kataras/iris"
)

type CmsCommentController struct {
	Service service.CmsCommentService
}

// list
func (c *CmsCommentController) Get(ctx iris.Context) {
	data, _ := c.Service.GetAll()
	ctx.JSON(iris.Map{"code": 0, "data": data})
}

// create
func (c *CmsCommentController) Post(ctx iris.Context) string {
	data := jwt.GetUser(ctx)
	fmt.Println("username", data["username"])
	return `create`
}

// info
func (c *CmsCommentController) GetBy(id int64) models.CmsComment {
	return c.Service.GetByID(id)
}

// update
func (*CmsCommentController) PutBy(id int64) string {
	return `update {id}`
}

// delete
func (*CmsCommentController) DeleteBy(id int64) string {
	return `delete {id}`
}
